Home About the Author Provide Feedback Game Development All Other Work

Push Button Java Application with a DialogMessage Display


In my second semester of university I worked on Java Object-Oriented Design, particularly focusing on this component of Object-Oriented programming.

The purpose of this project was to develop a push-button Java application so that it displays a Displaymessage box with some type of a question, or an explanation about some topic or an event.



  • Here as you can see we set up the name of our frame where our Button will be located.
  • we also want to set up a size for the layout as 1400 and 450.,/p>

  • tHE NEXT IMAGE OF OUR CODE SHOWS HOW WE SET UP 2 OBJECTS.
  • was you can see each object represented with a statement as a response such as 'good' or 'not so good./p>

  • The next image shows how we incorporated statement with our new buttons
  • Click here to see the image.

    As you see every statement is somewhat different and is assigned to that new button, so when you click on that button it print not only the name of the button but its statement./p>

  • These next images showcase declarations and how we incorporated statements within our new buttons
  • Click here for the images.

    Click here to view the image.

    As you see every statement is somewhat different and is assigned to that new button, so when you click on that button it print not only the name of the button but its statement./p>

    If you look closer you can see how every button is located within another button, meaning that when you click on one button it will open another button, and for every question there will be an explanation before an answer. So like 3 buttons in a sequential order. One after another.




  • ActionListeners are very important assignments when we are dealing with button declaration. So in this part of code we are adding all the action listeners to each assigned button, so that it perform an action once we call Action() method.


  • Color setting is crucial when making the appearance look organized and powerful.
  • Click here to see another two images.

    As you see the above image shows how we incorporated different colors to our buttons, so that it's not the same color every time we open a different button. Variety is very important. And certainly we want it to be visible./p>

  • HERE ARE MORE IMAGES of OUR CODE on a set up of our foreground colors.
  • Click here on the next image


  • nEXT YOU SEE IMAGES OF OU GridConstraints:
  • These constraints are positioning of our buttons on the grid layout. As was mentioned earlier, the structure is crucial, but knowing how to set up the right coordinates for our buttons is crucial. With this method we are able to organize our buttons in a consecutive order.../p>

  • Creating Errors and solutions to those errors can provide further actions on how to move on after that error is displayed.
  • Click here to view the image

    In the above image we have created few errors that we want our display box to show to the user, but some of these errors won't close even when you click OK/p>

  • Here is how we used looping with if/else to create a condition after another condition. So i order for the next button to open we need to click on the previous button, and this is how we have structured showMessageDialog and the rootPane to display all the buttons in a consecutive order. not at the same time, but one button at a time..

  • Click here to view the first 3 images


    Click here to view the next 3 images


    Click here to view the last 3 images


    tHIS IS HOW LOOPING IS HELPFUL WHEN using it to manage buttons within other buttons./p>


    We end our code application with the the { public static void main (String[] args }

    Click here to view the last 3 images


    the purpose is to call upon our function and method which is Actions();


    With this statement and request for action we will run the whole application with an opening to our grid and layout. Where we'll see all of our buttons listed.





    Let's run the application and see the output of our code:

































    Click here to view images in Group 1.


    Click here to view images in Group 2.


    Click here for images in Group 3.


    Go here to find images in Group 4.


    Visit here for images in Group 5.


    Click here for Group 6.


    Visit this link to view Group 7.


    Click on here to see Group 8.


    Go to images in Group 9.


    Check this link for Group 10 images.


    Check this Group 11.


    Visit here for more images in Group 12.


    Go to Group 13 images.





    If you would like to see the code on GitHub: Click here



    Click here to Go BACK to the Home page